//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Windows;
using System.Windows.Controls;

namespace OpenLS.Chart.UI.Internals
{
    static class PanelHelper
    {
        public static Size MeasureChildren(Size availableSize, UIElementCollection children, bool isHorizontal)
        {
            var result = new Size();
            foreach (UIElement e in children)
            {
                if (e == null)
                    continue;
                e.Measure(availableSize);
                if (isHorizontal)
                {
                    result.Width += e.DesiredSize.Width;
                    result.Height = Math.Max(result.Height, e.DesiredSize.Height);
                }
                else
                {
                    result.Height += e.DesiredSize.Height;
                    result.Width = Math.Max(result.Width, e.DesiredSize.Width);
                }
            }
            return result;

        }
        
    }
}